exports.install = function(Vue, options) {
	const API_HOST = 'http://192.168.0.102:6907/test/'

	Vue.prototype.getHost = function() {
		var url = window.location.href
		var urlArr = url.split('/')
		var urlStr = ''
		for (var i = 0; i < 4; i++) {
			urlStr = urlStr + urlArr[i] + '/'
		}
		return urlStr
	}

	Vue.prototype.get = function(url, data, success) {
		uni.request({
			method: 'GET',
			url: API_HOST + url,
			data: data,
			success: (res) => {
				success(res.data)
			},
			fail() {
				uni.showToast({
					title: '出现了一点小问题，请稍后重试',
					complete() {
						uni.hideToast()
					}
				})
			}
		})
	}

	Vue.prototype.post = function(url, data, success) {
		uni.request({
			method: 'POST',
			url: API_HOST + url,
			data,
			success(res) {
				success(res.data)
			},
			fail() {
				uni.showToast({
					title: '出现了一点小问题，请稍后重试',
					complete() {
						uni.hideToast()
					}
				})
			}
		})
	}
}
